import { createRouter,createWebHistory ,type RouteRecordRaw} from "vue-router";
import BlogLayout from "@/components/BlogLayout.vue";
import routeArticle from "@/views/ariticle-mng";
import routeAboutMe from "@/views/about-me"
import routeProject from "@/views/project-mng"
import routeHome from "@/views/home"
import routeLogin from "@/views/login";
export type MenuItem = {
  label:string,
  key:string,
  icon?:string,
  type?:string,
}

// 菜单列表
export const menus:MenuItem[]= [
  ...routeHome.menu,
  ...routeArticle.menu,
  ...routeAboutMe.menu,
  ...routeProject.menu,
]

// 路由列表
const routes:RouteRecordRaw[] = [
  ...routeHome.route,
  ...routeArticle.route,
  ...routeAboutMe.route,
  ...routeProject.route,
  ...routeLogin.route,
]
console.log('routes:',routes)
const initRouter = ()=>createRouter({
    history:createWebHistory(),
    routes:[
      {
        path:'/',
        name:'BlogLayout',
        component:BlogLayout,// 父路由的 component 是子路由的 “容器”。提供子路由组件展示的出口。必须要有。
        // 关键：重定向到 Home 命名路由（即 routeHome.route 中的/home）
        redirect: { name: 'Home' }, 
        children:routes,
      }
    ]
  })

export default initRouter